// Ext.Loader.setConfig({enabled: true});
//    Ext.Loader.setPath('Ext.ux', ctx+'/resources/extjs/ux');
//    Ext.require([
//        'Ext.ux.grid.PageToolBar'      
//    ]); 
Ext.define('HIT.view.MdataGoodsPanel', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.mdatagoodspanel',

    cls: 'custom-grid',
    frame: false,
    width: 1200,
    id: 'mdata-goods-main-panel',
    columnLines: false,
    autoScroll: true,
    store : 'MdataGoods',
    initComponent: function() {
        var me = this;
        Ext.applyIf(me, {
            columns: [
                {
                    xtype: 'rownumberer',
                    resizable: true,
                    width: 30
                },
                {
                    xtype: 'gridcolumn',
                    width: 160,
                    align: 'center',
                    dataIndex : 'code',
                    text: Share.T('代码')
                },
                {
                    xtype: 'gridcolumn',
                    width: 200,
                    align: 'left',
                    style:'text-align:center;',
                    dataIndex : 'name',
                    text: Share.T('货物名称')
                },
                {
                    xtype: 'gridcolumn',
                    align: 'left',
                    style:'text-align:center;',
                    width: 120,
                    dataIndex: 'tax_item',
                    text: Share.T('税目')
                },
                {
                    xtype: 'gridcolumn',
                    align: 'right',
                    style:'text-align:center;',
                    width: 120,
                    dataIndex: 'tax_rate',
                    text: Share.T('税率')
                },
                {
                    xtype: 'gridcolumn',
                    align: 'left',
                    style:'text-align:center;',
                    width: 120,
                    dataIndex: 'specification',
                    text: Share.T('规格')
                },
                {
                    xtype: 'gridcolumn',
                    align: 'left',
                    style:'text-align:center;',
                    width: 120,
                    dataIndex: 'measurement',
                    text: Share.T('计量单位')
                },
                {
                    xtype: 'gridcolumn',
                    align: 'right',
                    style:'text-align:center;',
                    width: 120,
                    dataIndex: 'default_price',
                    renderer: Ext.util.Format.numberRenderer('000,000,000.00'),
                    text: Share.T('单价')
                },
                {
                    xtype: 'gridcolumn',
                    align: 'left',
                    style:'text-align:center;',
                    width: 120,
                    dataIndex: 'shortcode',
                    text: Share.T('简码')
                }
            ],
            viewConfig: {
            	enableTextSelection:true
            },
            selModel: Ext.create('Ext.selection.CheckboxModel', {
                checkOnly: false
            }),
//            plugins :[{ptype:"rowselectionpaging"}],
            dockedItems: [
                {
                     xtype: 'pagingtoolbar',
                    dock: 'bottom',
                    width: 360,
                    inputItemWidth:45,
                    id:'mdata-goods-pag',
                    displayInfo: true,
                    store : 'MdataGoods',
                    plugins: [{
                        ptype: "pagesize",
                        uxPageSize: page_size}]
                },{
			    	xtype: 'toolbar',
					dock: 'top',
					items: [
					    {
					    	xtype: 'tbspacer',
					          width: 20
					    },
					    {
					    	xtype: 'textfield',
					    	labelwidth:40,
							width:234,
					    	id: 'mdata-goods-info-search',
					    	fieldLabel: Share.T('信息查询'),
					    	name: 'goods-info-search',
					    	listeners:{
					    		specialkey : function(field, e) {  
				                     if (e.getKey() == Ext.EventObject.ENTER) {  
//				                        alert("回车事件");  
				                    	Ext.getCmp('mdata-goods-info-btn').fireEvent("click");
				                     }  
				                 }  
					    	}	
					    },
					    {
					    	xtype: 'tbspacer',
					          width: 20
					    },
					    {
					    	xtype: 'button',
					    	id:'mdata-goods-info-btn',
					    	text: Share.T('查询'),
					    	listeners: {
					    			click: {
					    				fn: me.onMdataGoodsInfoSearch,
					                    scope: me
					    			}
					    	}
					    }
					]   	 
			    }
            ]
        });

        me.callParent(arguments);
    },
    onMdataGoodsInfoSearch: function(btn,event,eOpts){
    	var searchInfo = Ext.getCmp('mdata-goods-info-search').getValue();
    	var GoodsStore = Ext.getCmp('tab-mdata-goods').getStore();
    	if(!searchInfo){
//    		Ext.MessageBox.alert("错误","查询框无信息");
//    		return;
    		GoodsStore.load();
    	}else{
    		GoodsStore.load({
    			params: {searchInfo:searchInfo},
    			callback: function(records, options, success){
    				if(!records[0] || !records){
    					Share.ShowMessage("I0051");
    				}
    			},
    		    scope: GoodsStore,
    		    add: true
    		});
    	}
    }

});